|
@@ -103,7 +103,7 @@ on disk as a read-only file.
|
|
|
.. code-block:: python
|
|
.. code-block:: python
|
|
|
|
|
|
|
|
import os
|
|
import os
|
|
|
- kp = provider.security.key_pairs.create('cloudbridge_intro')
|
|
|
|
|
|
|
+ kp = provider.security.key_pairs.create('cloudbridge-intro')
|
|
|
with open('cloudbridge_intro.pem', 'w') as f:
|
|
with open('cloudbridge_intro.pem', 'w') as f:
|
|
|
f.write(kp.material)
|
|
f.write(kp.material)
|
|
|
os.chmod('cloudbridge_intro.pem', 0o400)
|
|
os.chmod('cloudbridge_intro.pem', 0o400)
|
|
@@ -136,7 +136,7 @@ a private network.
|
|
|
from cloudbridge.cloud.interfaces.resources import TrafficDirection
|
|
from cloudbridge.cloud.interfaces.resources import TrafficDirection
|
|
|
fw = provider.security.vm_firewalls.create(
|
|
fw = provider.security.vm_firewalls.create(
|
|
|
label='cloudbridge-intro', description='A VM firewall used by
|
|
label='cloudbridge-intro', description='A VM firewall used by
|
|
|
- CloudBridge', network=net.id)
|
|
|
|
|
|
|
+ CloudBridge', network_id=net.id)
|
|
|
fw.rules.create(TrafficDirection.INBOUND, 'tcp', 22, 22, '0.0.0.0/0')
|
|
fw.rules.create(TrafficDirection.INBOUND, 'tcp', 22, 22, '0.0.0.0/0')
|
|
|
|
|
|
|
|
Launch an instance
|
|
Launch an instance
|
|
@@ -148,12 +148,13 @@ also add the network interface as a launch argument.
|
|
|
.. code-block:: python
|
|
.. code-block:: python
|
|
|
|
|
|
|
|
img = provider.compute.images.get(image_id)
|
|
img = provider.compute.images.get(image_id)
|
|
|
|
|
+ zone = provider.compute.regions.get(provider.region_name).zones[0]
|
|
|
vm_type = sorted([t for t in provider.compute.vm_types
|
|
vm_type = sorted([t for t in provider.compute.vm_types
|
|
|
if t.vcpus >= 2 and t.ram >= 4],
|
|
if t.vcpus >= 2 and t.ram >= 4],
|
|
|
key=lambda x: x.vcpus*x.ram)[0]
|
|
key=lambda x: x.vcpus*x.ram)[0]
|
|
|
inst = provider.compute.instances.create(
|
|
inst = provider.compute.instances.create(
|
|
|
image=img, vm_type=vm_type, label='cloudbridge-intro',
|
|
image=img, vm_type=vm_type, label='cloudbridge-intro',
|
|
|
- subnet=sn, key_pair=kp, vm_firewalls=[fw])
|
|
|
|
|
|
|
+ subnet=sn, zone=zone, key_pair=kp, vm_firewalls=[fw])
|
|
|
# Wait until ready
|
|
# Wait until ready
|
|
|
inst.wait_till_ready() # This is a blocking call
|
|
inst.wait_till_ready() # This is a blocking call
|
|
|
# Show instance state
|
|
# Show instance state
|
|
@@ -201,7 +202,7 @@ listed in order to help map each resource with the service that handles it.
|
|
|
|
|
|
|
|
# Key Pair
|
|
# Key Pair
|
|
|
kp = provider.security.key_pairs.get('keypair ID')
|
|
kp = provider.security.key_pairs.get('keypair ID')
|
|
|
- kp_list = provider.security.key_pairs.find(name='cloudbridge_intro')
|
|
|
|
|
|
|
+ kp_list = provider.security.key_pairs.find(name='cloudbridge-intro')
|
|
|
kp = kp_list[0]
|
|
kp = kp_list[0]
|
|
|
|
|
|
|
|
# Network
|
|
# Network
|