Configure requirements for AAVMF(UEFI) with Cirros image on AArch64
[snaps.git] / examples / demo.py
1 import logging
2 logging.basicConfig(level=logging.INFO)
3
4 # Credentials
5 from snaps.openstack.os_credentials import OSCreds, ProxySettings
6
7
8 proxy_settings = ProxySettings(host='10.197.123.27', port='3128',
9                                ssh_proxy_cmd='/usr/local/bin/corkscrew 10.197.123.27 3128 %h %p')
10
11 os_creds = OSCreds(username='admin', password='cable123', auth_url='http://192.168.67.10:5000/v2.0/',
12                    project_name='admin', proxy_settings=proxy_settings)
13
14
15 # Images
16 from snaps.openstack.create_image import ImageSettings, OpenStackImage
17
18 image_settings = ImageSettings(name='cirros-test', image_user='cirros', img_format='qcow2',
19                                url='http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img')
20
21 image = OpenStackImage(os_creds, image_settings)
22 image.create()
23 # See in Horizon
24
25
26 # Network
27 from snaps.openstack.create_network import NetworkSettings, SubnetSettings, OpenStackNetwork
28
29 subnet_settings = SubnetSettings(name='test-subnet', cidr='10.0.0.1/24')
30 network_settings = NetworkSettings(name='test-net', subnet_settings=[subnet_settings])
31 network = OpenStackNetwork(os_creds, network_settings)
32 network.create()
33
34
35 # Flavors
36 from snaps.openstack.create_flavor import FlavorSettings, OpenStackFlavor
37
38 flavor_settings = FlavorSettings(name='test-flavor', ram=256, disk=10, vcpus=2)
39 flavor = OpenStackFlavor(os_creds, flavor_settings)
40 flavor.create()
41
42 # Instances
43 from snaps.openstack.create_network import PortSettings
44 from snaps.openstack.create_instance import VmInstanceSettings, OpenStackVmInstance
45
46 port_settings = PortSettings(name='test-port', network_name=network_settings.name)
47 instance_settings = VmInstanceSettings(name='test-inst', flavor=flavor_settings.name, port_settings=[port_settings])
48
49 vm_inst = OpenStackVmInstance(os_creds, instance_settings, image_settings)
50 vm_inst.create(block=True)
51
52 # Cleanup
53 vm_inst.clean()
54 flavor.clean()
55 network.clean()
56 image.clean()