Created
September 21, 2012 23:58
-
-
Save frodenas/3764572 to your computer and use it in GitHub Desktop.
Fog::Network OpenStack Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ fog | |
Welcome to fog interactive! | |
:default provides AWS, HP, OpenStack, Rackspace, VirtualBox and Vmfusion | |
>> quantum = Fog::Network.new(:provider => "OpenStack") | |
>> | |
?> # Create a new network: | |
?> quantum.networks.create(:name => "network_1") | |
<Fog::Network::OpenStack::Network | |
id="09b42312-bba6-4d52-a558-023e1de0d872", | |
name="network_1", | |
subnets=[], | |
shared=false, | |
status="ACTIVE", | |
admin_state_up=true, | |
tenant_id="f8b26a6032bc47718a7702233ac708b9" | |
> | |
>> | |
?> # Create a new subnet: | |
?> quantum.subnets.create(:name => "subnet_1", :network_id => "09b42312-bba6-4d52-a558-023e1de0d872", :cidr => "10.2.2.0/24", :ip_version => 4) | |
<Fog::Network::OpenStack::Subnet | |
id="5f8778f8-9a58-4fdd-b052-038003015a75", | |
name="subnet_1", | |
network_id="09b42312-bba6-4d52-a558-023e1de0d872", | |
cidr="10.2.2.0/24", | |
ip_version=4, | |
gateway_ip="10.2.2.1", | |
allocation_pools=[{"start"=>"10.2.2.2", "end"=>"10.2.2.254"}], | |
dns_nameservers=[], | |
host_routes=[], | |
enable_dhcp=true, | |
tenant_id="f8b26a6032bc47718a7702233ac708b9" | |
> | |
>> | |
?> # Create a new port: | |
?> quantum.ports.create(:name => "port_1", :network_id => "09b42312-bba6-4d52-a558-023e1de0d872") | |
<Fog::Network::OpenStack::Port | |
id="f734cd35-04c4-44ab-8a2b-7bc34de7c19b", | |
name="port_1", | |
network_id="09b42312-bba6-4d52-a558-023e1de0d872", | |
fixed_ips=[{"subnet_id"=>"5f8778f8-9a58-4fdd-b052-038003015a75", "ip_address"=>"10.2.2.3"}], | |
mac_address="fa:16:3e:bd:de:96", | |
status="ACTIVE", | |
admin_state_up=true, | |
device_owner="", | |
device_id="", | |
tenant_id="f8b26a6032bc47718a7702233ac708b9" | |
> | |
>> | |
?> # List all networks (with filters): | |
?> quantum.networks.all(:name => "network_1") | |
<Fog::Network::OpenStack::Networks | |
filters={:name=>"network_1"} | |
[ | |
<Fog::Network::OpenStack::Network | |
id="09b42312-bba6-4d52-a558-023e1de0d872", | |
name="network_1", | |
subnets=["5f8778f8-9a58-4fdd-b052-038003015a75"], | |
shared=false, | |
status="ACTIVE", | |
admin_state_up=true, | |
tenant_id="f8b26a6032bc47718a7702233ac708b9" | |
> | |
] | |
> | |
>> | |
?> # List all subnets (with filters): | |
?> quantum.subnets.all(:name => "subnet_1") | |
<Fog::Network::OpenStack::Subnets | |
filters={:name=>"subnet_1"} | |
[ | |
<Fog::Network::OpenStack::Subnet | |
id="5f8778f8-9a58-4fdd-b052-038003015a75", | |
name="subnet_1", | |
network_id="09b42312-bba6-4d52-a558-023e1de0d872", | |
cidr="10.2.2.0/24", | |
ip_version=4, | |
gateway_ip="10.2.2.1", | |
allocation_pools=[{"start"=>"10.2.2.2", "end"=>"10.2.2.254"}], | |
dns_nameservers=[], | |
host_routes=[], | |
enable_dhcp=true, | |
tenant_id="f8b26a6032bc47718a7702233ac708b9" | |
> | |
] | |
> | |
>> | |
?> # List all ports (with filters): | |
?> quantum.ports.all(:name => "port_1") | |
<Fog::Network::OpenStack::Ports | |
filters={:name=>"port_1"} | |
[ | |
<Fog::Network::OpenStack::Port | |
id="f734cd35-04c4-44ab-8a2b-7bc34de7c19b", | |
name="port_1", | |
network_id="09b42312-bba6-4d52-a558-023e1de0d872", | |
fixed_ips=[{"subnet_id"=>"5f8778f8-9a58-4fdd-b052-038003015a75", "ip_address"=>"10.2.2.3"}], | |
mac_address="fa:16:3e:bd:de:96", | |
status="ACTIVE", | |
admin_state_up=true, | |
device_owner="", | |
device_id="", | |
tenant_id="f8b26a6032bc47718a7702233ac708b9" | |
> | |
] | |
> | |
>> | |
?> # Get network details: | |
?> network = quantum.networks.get("09b42312-bba6-4d52-a558-023e1de0d872") | |
<Fog::Network::OpenStack::Network | |
id="09b42312-bba6-4d52-a558-023e1de0d872", | |
name="network_1", | |
subnets=["5f8778f8-9a58-4fdd-b052-038003015a75"], | |
shared=false, | |
status="ACTIVE", | |
admin_state_up=true, | |
tenant_id="f8b26a6032bc47718a7702233ac708b9" | |
> | |
>> | |
?> # Get subnet details: | |
?> subnet = quantum.subnets.get("5f8778f8-9a58-4fdd-b052-038003015a75") | |
<Fog::Network::OpenStack::Subnet | |
id="5f8778f8-9a58-4fdd-b052-038003015a75", | |
name="subnet_1", | |
network_id="09b42312-bba6-4d52-a558-023e1de0d872", | |
cidr="10.2.2.0/24", | |
ip_version=4, | |
gateway_ip="10.2.2.1", | |
allocation_pools=[{"start"=>"10.2.2.2", "end"=>"10.2.2.254"}], | |
dns_nameservers=[], | |
host_routes=[], | |
enable_dhcp=true, | |
tenant_id="f8b26a6032bc47718a7702233ac708b9" | |
> | |
>> | |
?> # Get port details: | |
?> port = quantum.ports.get("f734cd35-04c4-44ab-8a2b-7bc34de7c19b") | |
<Fog::Network::OpenStack::Port | |
id="f734cd35-04c4-44ab-8a2b-7bc34de7c19b", | |
name="port_1", | |
network_id="09b42312-bba6-4d52-a558-023e1de0d872", | |
fixed_ips=[{"subnet_id"=>"5f8778f8-9a58-4fdd-b052-038003015a75", "ip_address"=>"10.2.2.3"}], | |
mac_address="fa:16:3e:bd:de:96", | |
status="ACTIVE", | |
admin_state_up=true, | |
device_owner="", | |
device_id="", | |
tenant_id="f8b26a6032bc47718a7702233ac708b9" | |
> | |
>> | |
?> # Update network details: | |
?> network.name = "network_new" | |
"network_new" | |
>> network.save | |
<Fog::Network::OpenStack::Network | |
id="09b42312-bba6-4d52-a558-023e1de0d872", | |
name="network_new", | |
subnets=["5f8778f8-9a58-4fdd-b052-038003015a75"], | |
shared=false, | |
status="ACTIVE", | |
admin_state_up=true, | |
tenant_id="f8b26a6032bc47718a7702233ac708b9" | |
> | |
>> | |
?> # Update subnet details: | |
?> subnet.name = "subnet_new" | |
"subnet_new" | |
>> subnet.save | |
<Fog::Network::OpenStack::Subnet | |
id="5f8778f8-9a58-4fdd-b052-038003015a75", | |
name="subnet_new", | |
network_id="09b42312-bba6-4d52-a558-023e1de0d872", | |
cidr="10.2.2.0/24", | |
ip_version=4, | |
gateway_ip="10.2.2.1", | |
allocation_pools=[{"start"=>"10.2.2.2", "end"=>"10.2.2.254"}], | |
dns_nameservers=[], | |
host_routes=[], | |
enable_dhcp=true, | |
tenant_id="f8b26a6032bc47718a7702233ac708b9" | |
> | |
>> | |
?> # Update port details: | |
?> port.name = "port_new" | |
"port_new" | |
>> port.save | |
<Fog::Network::OpenStack::Port | |
id="f734cd35-04c4-44ab-8a2b-7bc34de7c19b", | |
name="port_new", | |
network_id="09b42312-bba6-4d52-a558-023e1de0d872", | |
fixed_ips=[{"subnet_id"=>"5f8778f8-9a58-4fdd-b052-038003015a75", "ip_address"=>"10.2.2.3"}], | |
mac_address="fa:16:3e:bd:de:96", | |
status="ACTIVE", | |
admin_state_up=true, | |
device_owner="", | |
device_id="", | |
tenant_id="f8b26a6032bc47718a7702233ac708b9" | |
> | |
>> | |
?> # Delete port: | |
?> port.destroy | |
true | |
>> | |
?> # Delete subnet: | |
?> subnet.destroy | |
true | |
>> | |
?> # Delete network: | |
?> network.destroy | |
true | |
>> | |
?> # List all ports: | |
?> quantum.ports | |
<Fog::Network::OpenStack::Ports | |
filters={} | |
[] | |
> | |
>> | |
?> # List all subnets: | |
?> quantum.subnets | |
<Fog::Network::OpenStack::Subnets | |
filters={} | |
[] | |
> | |
>> | |
?> # List all networks: | |
?> quantum.networks | |
<Fog::Network::OpenStack::Networks | |
filters={} | |
[] | |
> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment