- self.logger.info("Upload some OS images if it doesn't exist")
- temp_dir = os.path.join(self.data_dir, "tmp/")
- for image_name, image_url in self.images.iteritems():
- self.logger.info("image: %s, url: %s", image_name, image_url)
- try:
- image_id = os_utils.get_image_id(self.glance_client,
- image_name)
- self.logger.debug("image_id: %s", image_id)
- except Exception:
- self.logger.error("Unexpected error: %s", sys.exc_info()[0])
-
- if image_id == '':
- self.logger.info("""%s image does not exist on glance repo.
- Try downloading this image
- and upload on glance !""",
- image_name)
- image_id = os_utils.download_and_add_image_on_glance(
- self.glance_client,
- image_name,
- image_url,
- temp_dir)
- # Need to extend quota
- self.logger.info("Update security group quota for this tenant")
- tenant_id = os_utils.get_tenant_id(self.keystone_client,
- self.tenant_name)
- self.logger.debug("Tenant id found %s", tenant_id)
- if not os_utils.update_sg_quota(self.neutron_client,
- tenant_id, 50, 100):
- self.logger.error("Failed to update security group quota"
- " for tenant " + self.tenant_name)
-
- self.logger.debug("group quota extended")
-
- # start the deployment of cloudify
- public_auth_url = os_utils.get_endpoint('identity')
-
- self.logger.debug("CFY inputs: %s", self.orchestrator['inputs'])
- cfy = Orchestrator(self.data_dir, self.orchestrator['inputs'])
- self.orchestrator['object'] = cfy
- self.logger.debug("Orchestrator object created")
-
- self.logger.debug("Tenant name: %s", self.tenant_name)
-
- cfy.set_credentials(username=self.tenant_name,
- password=self.tenant_name,
- tenant_name=self.tenant_name,
- auth_url=public_auth_url)
- self.logger.info("Credentials set in CFY")
+ self.__logger.info("Upload some OS images if it doesn't exist")
+ for image_name, image_file in self.images.iteritems():
+ self.__logger.info("image: %s, file: %s", image_name, image_file)
+ if image_file and image_name:
+ image_creator = OpenStackImage(
+ self.snaps_creds,
+ ImageConfig(
+ name=image_name, image_user='cloud',
+ img_format='qcow2', image_file=image_file))
+ image_creator.create()
+ self.created_object.append(image_creator)
+
+ def deploy_orchestrator(self):
+ """
+ Deploy Cloudify Manager.
+
+ network, security group, fip, VM creation
+ """
+ # network creation
+
+ start_time = time.time()
+ self.__logger.info("Creating keypair ...")
+ kp_file = os.path.join(self.data_dir, "cloudify_ims.pem")
+ keypair_settings = KeypairConfig(
+ name='cloudify_ims_kp-{}'.format(self.uuid),
+ private_filepath=kp_file)
+ keypair_creator = OpenStackKeypair(self.snaps_creds, keypair_settings)
+ keypair_creator.create()
+ self.created_object.append(keypair_creator)
+
+ self.__logger.info("Creating full network ...")
+ subnet_settings = SubnetConfig(
+ name='cloudify_ims_subnet-{}'.format(self.uuid),
+ cidr='10.67.79.0/24',
+ dns_nameservers=[env.get('NAMESERVER')])
+ network_settings = NetworkConfig(
+ name='cloudify_ims_network-{}'.format(self.uuid),
+ subnet_settings=[subnet_settings])
+ network_creator = OpenStackNetwork(self.snaps_creds, network_settings)
+ network_creator.create()
+ self.created_object.append(network_creator)
+ ext_net_name = snaps_utils.get_ext_net_name(self.snaps_creds)
+ router_creator = OpenStackRouter(
+ self.snaps_creds,
+ RouterConfig(
+ name='cloudify_ims_router-{}'.format(self.uuid),
+ external_gateway=ext_net_name,
+ internal_subnets=[subnet_settings.name]))
+ router_creator.create()
+ self.created_object.append(router_creator)
+
+ # security group creation
+ self.__logger.info("Creating security group for cloudify manager vm")
+ sg_rules = list()
+ sg_rules.append(
+ SecurityGroupRuleConfig(
+ sec_grp_name="sg-cloudify-manager-{}".format(self.uuid),
+ direction=Direction.ingress, protocol=Protocol.tcp,
+ port_range_min=1, port_range_max=65535))
+ sg_rules.append(
+ SecurityGroupRuleConfig(
+ sec_grp_name="sg-cloudify-manager-{}".format(self.uuid),
+ direction=Direction.ingress, protocol=Protocol.udp,
+ port_range_min=1, port_range_max=65535))
+
+ security_group_creator = OpenStackSecurityGroup(
+ self.snaps_creds,
+ SecurityGroupConfig(
+ name="sg-cloudify-manager-{}".format(self.uuid),
+ rule_settings=sg_rules))
+
+ security_group_creator.create()
+ self.created_object.append(security_group_creator)