def init(self, attrs): """Initializes itself from the supplied arguments""" super(HeatContext, self).init(attrs) self.check_environment() self._user = attrs.get("user") self.template_file = attrs.get("heat_template") self.shade_client = openstack_utils.get_shade_client() self.operator_client = openstack_utils.get_shade_operator_client() try: self.read_pod_file(attrs) except IOError: LOG.warning("No pod file specified. NVFi metrics will be disabled") self.heat_timeout = attrs.get("timeout", DEFAULT_HEAT_TIMEOUT) if self.template_file: self.heat_parameters = attrs.get("heat_parameters") return self.keypair_name = h_join(self.name, "key") self.secgroup_name = h_join(self.name, "secgroup") self.security_group = attrs.get("security_group") self._image = attrs.get("image") self._flavor = attrs.get("flavor") self.placement_groups = [ PlacementGroup(name, self, pg_attrs["policy"]) for name, pg_attrs in attrs.get("placement_groups", {}).items() ] self.server_groups = [ ServerGroup(name, self, sg_attrs["policy"]) for name, sg_attrs in attrs.get("server_groups", {}).items() ] # we have to do this first, because we are injecting external_network # into the dict sorted_networks = self.assign_external_network(attrs["networks"]) self.networks = OrderedDict((name, Network(name, self, net_attrs)) for name, net_attrs in sorted_networks) for name, server_attrs in sorted(attrs["servers"].items()): server = Server(name, self, server_attrs) self.servers.append(server) self._server_map[server.dn] = server self.attrs = attrs
def init(self, attrs): """Initializes itself from the supplied arguments""" super(HeatContext, self).init(attrs) self.check_environment() self._user = attrs.get("user") self.template_file = attrs.get("heat_template") self.heat_timeout = attrs.get("timeout", DEFAULT_HEAT_TIMEOUT) if self.template_file: self.heat_parameters = attrs.get("heat_parameters") return self.keypair_name = h_join(self.name, "key") self.secgroup_name = h_join(self.name, "secgroup") self._image = attrs.get("image") self._flavor = attrs.get("flavor") self.placement_groups = [ PlacementGroup(name, self, pg_attrs["policy"]) for name, pg_attrs in attrs.get("placement_groups", {}).items() ] self.server_groups = [ ServerGroup(name, self, sg_attrs["policy"]) for name, sg_attrs in attrs.get("server_groups", {}).items() ] # we have to do this first, because we are injecting external_network # into the dict sorted_networks = self.assign_external_network(attrs["networks"]) self.networks = OrderedDict((name, Network(name, self, net_attrs)) for name, net_attrs in sorted_networks) for name, server_attrs in sorted(attrs["servers"].items()): server = Server(name, self, server_attrs) self.servers.append(server) self._server_map[server.dn] = server self.attrs = attrs self.key_filename = ''.join([ consts.YARDSTICK_ROOT_PATH, 'yardstick/resources/files/yardstick_key-', self.name ]) # Permissions may have changed since creation; this can be fixed. If we # overwrite the file, we lose future access to VMs using this key. # As long as the file exists, even if it is unreadable, keep it intact if not os.path.exists(self.key_filename): SSH.gen_keys(self.key_filename)
def init(self, attrs): # pragma: no cover """initializes itself from the supplied arguments""" self.name = attrs["name"] self._user = attrs.get("user") self.template_file = attrs.get("heat_template") if self.template_file: self.heat_parameters = attrs.get("heat_parameters") return self.keypair_name = self.name + "-key" self.secgroup_name = self.name + "-secgroup" self._image = attrs.get("image") self._flavor = attrs.get("flavor") self.heat_timeout = attrs.get("timeout", DEFAULT_HEAT_TIMEOUT) self.placement_groups = [PlacementGroup(name, self, pgattrs["policy"]) for name, pgattrs in attrs.get( "placement_groups", {}).items()] self.server_groups = [ServerGroup(name, self, sgattrs["policy"]) for name, sgattrs in attrs.get( "server_groups", {}).items()] # we have to do this first, because we are injecting external_network # into the dict sorted_networks = self.assign_external_network(attrs["networks"]) self.networks = OrderedDict( (name, Network(name, self, netattrs)) for name, netattrs in sorted_networks) for name, serverattrs in sorted(attrs["servers"].items()): server = Server(name, self, serverattrs) self.servers.append(server) self._server_map[server.dn] = server rsa_key = paramiko.RSAKey.generate(bits=2048, progress_func=None) rsa_key.write_private_key_file(self.key_filename) print("Writing %s ..." % self.key_filename) with open(self.key_filename + ".pub", "w") as pubkey_file: pubkey_file.write( "%s %s\n" % (rsa_key.get_name(), rsa_key.get_base64())) del rsa_key
def init(self, attrs): '''initializes itself from the supplied arguments''' self.name = attrs["name"] if "user" in attrs: self._user = attrs["user"] if "heat_template" in attrs: self.template_file = attrs["heat_template"] self.heat_parameters = attrs.get("heat_parameters", None) return self.keypair_name = self.name + "-key" self.secgroup_name = self.name + "-secgroup" if "image" in attrs: self._image = attrs["image"] if "flavor" in attrs: self._flavor = attrs["flavor"] if "placement_groups" in attrs: for name, pgattrs in attrs["placement_groups"].items(): pg = PlacementGroup(name, self, pgattrs["policy"]) self.placement_groups.append(pg) if "server_groups" in attrs: for name, sgattrs in attrs["server_groups"].items(): sg = ServerGroup(name, self, sgattrs["policy"]) self.server_groups.append(sg) for name, netattrs in attrs["networks"].items(): network = Network(name, self, netattrs) self.networks.append(network) for name, serverattrs in attrs["servers"].items(): server = Server(name, self, serverattrs) self.servers.append(server) self._server_map[server.dn] = server rsa_key = paramiko.RSAKey.generate(bits=2048, progress_func=None) rsa_key.write_private_key_file(self.key_filename) open(self.key_filename + ".pub", "w").write("%s %s\n" % (rsa_key.get_name(), rsa_key.get_base64())) del rsa_key
def init(self, attrs): self.check_environment() """initializes itself from the supplied arguments""" self.name = attrs["name"] self._user = attrs.get("user") self.template_file = attrs.get("heat_template") if self.template_file: self.heat_parameters = attrs.get("heat_parameters") return self.keypair_name = h_join(self.name, "key") self.secgroup_name = h_join(self.name, "secgroup") self._image = attrs.get("image") self._flavor = attrs.get("flavor") self.heat_timeout = attrs.get("timeout", DEFAULT_HEAT_TIMEOUT) self.placement_groups = [ PlacementGroup(name, self, pg_attrs["policy"]) for name, pg_attrs in attrs.get("placement_groups", {}).items() ] self.server_groups = [ ServerGroup(name, self, sg_attrs["policy"]) for name, sg_attrs in attrs.get("server_groups", {}).items() ] # we have to do this first, because we are injecting external_network # into the dict sorted_networks = self.assign_external_network(attrs["networks"]) self.networks = OrderedDict((name, Network(name, self, net_attrs)) for name, net_attrs in sorted_networks) for name, server_attrs in sorted(attrs["servers"].items()): server = Server(name, self, server_attrs) self.servers.append(server) self._server_map[server.dn] = server self.attrs = attrs SSH.gen_keys(self.key_filename)