add sample code create node uncustomised
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/096b6065 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/096b6065 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/096b6065 Branch: refs/heads/trunk Commit: 096b6065f8454ff70b07dc45b9fc24619397ab8b Parents: 168c7a1 Author: Samuel Chong <[email protected]> Authored: Thu Jan 5 11:03:21 2017 +1100 Committer: Anthony Shaw <[email protected]> Committed: Tue Feb 21 17:17:27 2017 +0100 ---------------------------------------------------------------------- .../Nodes_Create_mcp2_Uncustomised.py | 56 ++++++++++++++++++++ 1 file changed, 56 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/096b6065/docs/examples/compute/dimensiondata/Nodes_Create_mcp2_Uncustomised.py ---------------------------------------------------------------------- diff --git a/docs/examples/compute/dimensiondata/Nodes_Create_mcp2_Uncustomised.py b/docs/examples/compute/dimensiondata/Nodes_Create_mcp2_Uncustomised.py new file mode 100644 index 0000000..f0b4042 --- /dev/null +++ b/docs/examples/compute/dimensiondata/Nodes_Create_mcp2_Uncustomised.py @@ -0,0 +1,56 @@ +from pprint import pprint +from libcloud.compute.types import Provider +from libcloud.compute.providers import get_driver +import libcloud.security + +# Get dimension data driver +libcloud.security.VERIFY_SSL_CERT = True +cls = get_driver(Provider.DIMENSIONDATA) +driver = cls('myusername','mypassword', region='dd-au') + +# Get location +location = driver.ex_get_location_by_id(id='AU9') + +# Get network domain by location +networkDomainName = "Test Apache Libcloud" +network_domains = driver.ex_list_network_domains(location=location) +my_network_domain = [d for d in network_domains if d.name == networkDomainName][0] + +vlan = driver.ex_list_vlans(name='Libcloud Test VLAN')[0] + +# Get Image +images = driver.ex_list_customer_images(location=location) +image = images[1] + +tags = driver.ex_list_tags() +pprint(tags) + +ex_tagname_value_pairs = {} +ex_tagname_value_pairs['AA_Tag1'] = 'demo 1' +ex_tagname_value_pairs['AA_Tag2'] = 'demo 2' + +ex_tagid_value_pairs = {} +ex_tagid_value_pairs['4927c8fd-7f41-4206-a7d5-c5def927c6d2'] = 'demo 1' +ex_tagid_value_pairs['2579fc7c-a89c-47cd-ac3b-67999dded93b'] = 'demo 2' + + +# Create node using vlan instead of private IPv4 +node = driver.ex_create_node_uncustomized( + name='test_server_05', + image=image, + ex_network_domain=my_network_domain, + ex_is_started=False, + ex_description=None, + ex_cluster_id=None, + ex_cpu_specification=None, + ex_memory_gb=None, + ex_primary_nic_private_ipv4=None, + ex_primary_nic_vlan=vlan, + ex_primary_nic_network_adapter=None, + ex_additional_nics=None, + ex_disks=None, + ex_tagid_value_pairs=ex_tagid_value_pairs, + ex_tagname_value_pairs=None +) + +pprint(node)
