def virtual_node_create(self, name='testtest03'): kernel_id = self.get_kernel_image_id() ramdisk_id = self.get_ramdisk_image_id() quashfs_id = self.get_quashfs_image_id() ip_addr = self.get_ip() virtual_node = self.shell('ironic node-create -n {0} -d fuel_ssh -i deploy_kernel={1} -i deploy_ramdisk={2} -i deploy_squashfs={3} -i ssh_address={4} -i ssh_password=ironic_password -i ssh_username=ironic -i ssh_virt_type=virsh -p cpus=2 -p memory_mb=3072 -p local_gb=150 -p cpu_arch=x86_64'.format(name, kernel_id, ramdisk_id, quashfs_id, ip_addr)) return parser.listing(virtual_node)
def virt_flavor_create(self, name='bm_flavor'): flavor_list = self.get_flavor_list() if name in [x['Name'] for x in flavor_list]: return flavor = self.shell('nova flavor-create {0} auto 3072 150 2' .format(name)) return parser.listing(flavor)
def user_create(self, name): user = self.shell('openstack user create \ --project {0} \ --password {0} \ --email {0}@example.com \ --enable {0}'.format(name)) user = parser.listing(user) return [x['Value'] for x in user if 'id' in x.values()][0]
def net_create(self, net_name, geatway, net_cidr): """Returns dict. To get network id use key: 'network_id' """ self.shell('neutron net-create {0}'.format(net_name)) subnet_name = 'sub-{0}'.format(net_name) subnet = self.shell('neutron subnet-create {0} \ --name {1} \ --gateway {2} {3}' .format(net_name, subnet_name, geatway, net_cidr)) subnet = parser.listing(subnet) subnet_dict = {} for _ in subnet: subnet_dict[_.values()[0]] = _.values()[-1] return subnet_dict
def get_flavor_list(self): flavor = self.shell('nova flavor-list') return parser.listing(flavor)
def get_tenant_list(self): tenant_list = self.shell('openstack project list') return parser.listing(tenant_list)
def get_user_list(self): user = self.shell('openstack user list') return parser.listing(user)
def tenant_create(self, name): tenant = self.shell('openstack project create {0}'.format(name)) tenant = parser.listing(tenant) return [x['Value'] for x in tenant if 'id' in x.values()][0]
def get_key_list(self): key_list = self.shell('nova keypair-list') return parser.listing(key_list)
def get_instance_list_ids(self): instance_list = self.shell('nova list') instance_list = parser.listing(instance_list) return [x['ID'] for x in instance_list]
def get_quashfs_image_id(self): image_list = self.shell('glance image-list') image_list = parser.listing(image_list) return [x['ID'] for x in image_list if x['Name'] == 'ironic-deploy-squashfs'][0]
def get_image_list(self): image_list = self.shell('glance image-list') return parser.listing(image_list)
def get_nova_list(self): nova_list = self.shell('nova list') return parser.listing(nova_list)
def get_floating_ip_list(self): floating_ip_list = self.shell('nova floating-ip-list') return parser.listing(floating_ip_list)
def get_net_list(self): net_list = self.shell('neutron net-list') return parser.listing(net_list)