def _restart_exports(self): if FLAGS.fake_storage: return utils.runthis("Setting exports to auto: %s", "sudo vblade-persist auto all") utils.runthis("Starting all exports: %s", "sudo vblade-persist start all")
def _remove_export(self): utils.runthis( "Stopped AOE export: %s", "sudo vblade-persist stop %s %s" % (self['shelf_id'], self['blade_id'])) utils.runthis( "Destroyed AOE export: %s", "sudo vblade-persist destroy %s %s" % (self['shelf_id'], self['blade_id']))
def setup_export(self): (shelf_id, blade_id) = get_next_aoe_numbers() self['aoe_device'] = "e%s.%s" % (shelf_id, blade_id) self.save() utils.runthis("Creating AOE export: %s", "sudo vblade-persist setup %s %s %s /dev/%s/%s" % (shelf_id, blade_id, FLAGS.aoe_eth_dev, FLAGS.volume_group, self.volume_id))
def _remove_export(self): runthis( "Destroyed AOE export: %s", "sudo vblade-persist stop %s %s" % (self.aoe_device[1], self.aoe_device[3])) runthis( "Destroyed AOE export: %s", "sudo vblade-persist destroy %s %s" % (self.aoe_device[1], self.aoe_device[3]))
def _exec_export(self): utils.runthis("Creating AOE export: %s", "sudo vblade-persist setup %s %s %s /dev/%s/%s" % (self['shelf_id'], self['blade_id'], FLAGS.aoe_eth_dev, FLAGS.volume_group, self['volume_id']))
def create_lv(self): if str(self['size']) == '0': sizestr = '100M' else: sizestr = '%sG' % self['size'] utils.runthis( "Creating LV: %s", "sudo lvcreate -L %s -n %s %s" % (sizestr, self['volume_id'], FLAGS.volume_group))
def detach_volume(self, instance_id, mountpoint): """ detach a volume from an instance """ # despite the documentation, virsh detach-disk just wants the device # name without the leading /dev/ target = mountpoint.rpartition('/dev/')[2] utils.runthis("Detached Volume: %s", "sudo virsh detach-disk %s %s " % (instance_id, target)) return defer.succeed(True)
def _init_volume_group(self): if FLAGS.fake_storage: return runthis("PVCreate returned: %s", "sudo pvcreate %s" % (FLAGS.storage_dev)) runthis( "VGCreate returned: %s", "sudo vgcreate %s %s" % (FLAGS.volume_group, FLAGS.storage_dev))
def _setup_export(self): (shelf_id, blade_id) = get_next_aoe_numbers() self.aoe_device = "e%s.%s" % (shelf_id, blade_id) runthis( "Creating AOE export: %s", "sudo vblade-persist setup %s %s %s /dev/%s/%s" % (shelf_id, blade_id, FLAGS.aoe_eth_dev, FLAGS.volume_group, self.volume_id))
def attach_volume(self, instance_id=None, aoe_device=None, mountpoint=None): utils.runthis( "Attached Volume: %s", "sudo virsh attach-disk %s /dev/etherd/%s %s" % (instance_id, aoe_device, mountpoint.split("/")[-1])) return defer.succeed(True)
def detach_volume(self, instance_id, volume_id): """ detach a volume from an instance """ # despite the documentation, virsh detach-disk just wants the device # name without the leading /dev/ volume = storage.get_volume(volume_id) target = volume['mountpoint'].rpartition('/dev/')[2] utils.runthis("Detached Volume: %s", "sudo virsh detach-disk %s %s " % (instance_id, target)) volume.finish_detach() return defer.succeed(True)
def setup(self): # Create keys folder, if it doesn't exist if not os.path.exists(FLAGS.keys_path): os.makedirs(os.path.abspath(FLAGS.keys_path)) # Gen root CA, if we don't have one root_ca_path = os.path.join(FLAGS.ca_path, FLAGS.ca_file) if not os.path.exists(root_ca_path): start = os.getcwd() os.chdir(FLAGS.ca_path) runthis("Generating root CA: %s", "sh genrootca.sh") os.chdir(start)
def setup_export(self): (shelf_id, blade_id) = get_next_aoe_numbers() self['aoe_device'] = "e%s.%s" % (shelf_id, blade_id) self['shelf_id'] = shelf_id self['blade_id'] = blade_id self.save() utils.runthis( "Creating AOE export: %s", "sudo vblade-persist setup %s %s %s /dev/%s/%s" % (shelf_id, blade_id, FLAGS.aoe_eth_dev, FLAGS.volume_group, self['volume_id']))
def setup(self): """ Ensure the keychains and folders exist. """ # FIXME(ja): this should be moved to a nova-manage command, # if not setup throw exceptions instead of running # Create keys folder, if it doesn't exist if not os.path.exists(FLAGS.keys_path): os.makedirs(FLAGS.keys_path) # Gen root CA, if we don't have one root_ca_path = os.path.join(FLAGS.ca_path, FLAGS.ca_file) if not os.path.exists(root_ca_path): start = os.getcwd() os.chdir(FLAGS.ca_path) # TODO(vish): Do this with M2Crypto instead utils.runthis(_("Generating root CA: %s"), "sh genrootca.sh") os.chdir(start)
def express(self, address=None): logging.debug("Todo - need to create IPTables natting entries for this net.") addresses = self.hosts.values() if address: addresses = [self.hosts[address]] for addr in addresses: if not addr.has_key('private_ip'): continue public_ip = addr['address'] private_ip = addr['private_ip'] runthis("Binding IP to interface: %s", "sudo ip addr add %s dev %s" % (public_ip, FLAGS.public_interface)) confirm_rule("PREROUTING -t nat -d %s -j DNAT --to %s" % (public_ip, private_ip)) confirm_rule("POSTROUTING -t nat -s %s -j SNAT --to %s" % (private_ip, public_ip)) # TODO: Get these from the secgroup datastore entries confirm_rule("FORWARD -d %s -p icmp -j ACCEPT" % (private_ip)) for (protocol, port) in [("tcp",80), ("tcp",22), ("udp",1194), ("tcp",443)]: confirm_rule("FORWARD -d %s -p %s --dport %s -j ACCEPT" % (private_ip, protocol, port))
def attach_volume(self, instance_id=None, volume_id=None, mountpoint=None): volume = storage.get_volume(volume_id) yield self._init_aoe() yield utils.runthis( "Attached Volume: %s", "sudo virsh attach-disk %s /dev/etherd/%s %s" % (instance_id, volume['aoe_device'], mountpoint.split("/")[-1])) volume.finish_attach() defer.returnValue(True)
def attach_volume(self, instance_id = None, volume_id = None, mountpoint = None): volume = storage.get_volume(volume_id) yield self._init_aoe() yield utils.runthis("Attached Volume: %s", "sudo virsh attach-disk %s /dev/etherd/%s %s" % (instance_id, volume['aoe_device'], mountpoint.split("/")[-1])) volume.finish_attach() defer.returnValue(True)
def setup(self): """ Ensure the keychains and folders exist. """ # FIXME(ja): this should be moved to a nova-manage command, # if not setup throw exceptions instead of running # Create keys folder, if it doesn't exist if not os.path.exists(FLAGS.keys_path): os.makedirs(FLAGS.keys_path) # Gen root CA, if we don't have one root_ca_path = os.path.join(FLAGS.ca_path, FLAGS.ca_file) if not os.path.exists(root_ca_path): genrootca_sh_path = os.path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardir, 'CA', 'genrootca.sh') start = os.getcwd() if not os.path.exists(FLAGS.ca_path): os.makedirs(FLAGS.ca_path) os.chdir(FLAGS.ca_path) # TODO(vish): Do this with M2Crypto instead utils.runthis(_("Generating root CA: %s"), "sh", genrootca_sh_path) os.chdir(start)
def setup(self): """Ensure the keychains and folders exist.""" # TODO(todd): this was copyed from api.ec2.cloud # FIXME(ja): this should be moved to a nova-manage command, # if not setup throw exceptions instead of running # Create keys folder, if it doesn't exist if not os.path.exists(FLAGS.keys_path): os.makedirs(FLAGS.keys_path) # Gen root CA, if we don't have one root_ca_path = os.path.join(FLAGS.ca_path, FLAGS.ca_file) if not os.path.exists(root_ca_path): genrootca_sh_path = os.path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardir, 'CA', 'genrootca.sh') start = os.getcwd() if not os.path.exists(FLAGS.ca_path): os.makedirs(FLAGS.ca_path) os.chdir(FLAGS.ca_path) # TODO(vish): Do this with M2Crypto instead utils.runthis(_("Generating root CA: %s"), "sh", genrootca_sh_path) os.chdir(start)
def express(self, address=None): logging.debug( "Todo - need to create IPTables natting entries for this net.") addresses = self.hosts.values() if address: addresses = [self.hosts[address]] for addr in addresses: if not addr.has_key('private_ip'): continue public_ip = addr['address'] private_ip = addr['private_ip'] runthis( "Binding IP to interface: %s", "sudo ip addr add %s dev %s" % (public_ip, FLAGS.public_interface)) confirm_rule("PREROUTING -t nat -d %s -j DNAT --to %s" % (public_ip, private_ip)) confirm_rule("POSTROUTING -t nat -s %s -j SNAT --to %s" % (private_ip, public_ip)) # TODO: Get these from the secgroup datastore entries confirm_rule("FORWARD -d %s -p icmp -j ACCEPT" % (private_ip)) for (protocol, port) in [("tcp", 80), ("tcp", 22), ("udp", 1194), ("tcp", 443)]: confirm_rule("FORWARD -d %s -p %s --dport %s -j ACCEPT" % (private_ip, protocol, port))
def attach_volume(self, instance_id = None, aoe_device = None, mountpoint = None): runthis("Attached Volume: %s", "sudo virsh attach-disk %s /dev/etherd/%s %s" % (instance_id, aoe_device, mountpoint.split("/")[-1])) return defer.succeed(True)
def _init_aoe(self): utils.runthis("Doin an AoE discover, returns %s", "sudo aoe-discover") utils.runthis("Doin an AoE stat, returns %s", "sudo aoe-stat")
def detach_volume(self, instance_id, mountpoint): """ detach a volume from an instance """ runthis("Detached Volume: %s", "sudo virsh detach-disk %s %s " % (instance_id, mountpoint)) return defer.succeed(True)
def _remove_export(self): utils.runthis("Stopped AOE export: %s", "sudo vblade-persist stop %s %s" % (self['shelf_id'], self['blade_id'])) utils.runthis("Destroyed AOE export: %s", "sudo vblade-persist destroy %s %s" % (self['shelf_id'], self['blade_id']))
def _delete_lv(self): utils.runthis( "Removing LV: %s", "sudo lvremove -f %s/%s" % (FLAGS.volume_group, self['volume_id']))
def _restart_exports(self): if FLAGS.fake_storage: return runthis("Setting exports to auto: %s", "sudo vblade-persist auto all") runthis("Starting all exports: %s", "sudo vblade-persist start all") runthis("Discovering AOE devices: %s", "sudo aoe-discover")
def _create_lv(self, size): runthis("Creating LV: %s", "sudo lvcreate -L %s -n %s %s" % (size, self.volume_id, FLAGS.volume_group))
def _create_lv(self, size): runthis( "Creating LV: %s", "sudo lvcreate -L %s -n %s %s" % (size, self.volume_id, FLAGS.volume_group))
def _delete_lv(self): utils.runthis("Removing LV: %s", "sudo lvremove -f %s/%s" % (FLAGS.volume_group, self.volume_id))
def create_lv(self): if str(self['size']) == '0': sizestr = '100M' else: sizestr = '%sG' % self['size'] utils.runthis("Creating LV: %s", "sudo lvcreate -L %s -n %s %s" % (sizestr, self.volume_id, FLAGS.volume_group))
def _init_volume_group(self): if FLAGS.fake_storage: return utils.runthis("PVCreate returned: %s", "sudo pvcreate %s" % (FLAGS.storage_dev)) utils.runthis("VGCreate returned: %s", "sudo vgcreate %s %s" % (FLAGS.volume_group, FLAGS.storage_dev))
def _restart_exports(self): if FLAGS.fake_storage: return utils.runthis("Setting exports to auto: %s", "sudo vblade-persist auto all") utils.runthis("Starting all exports: %s", "sudo vblade-persist start all") utils.runthis("Discovering AOE devices: %s", "sudo aoe-discover")
def _delete_lv(self): runthis( "Removing LV: %s", "sudo lvremove -f %s/%s" % (FLAGS.volume_group, self.volume_id))
def _remove_export(self): utils.runthis("Destroyed AOE export: %s", "sudo vblade-persist stop %s %s" % (self.aoe_device[1], self.aoe_device[3])) utils.runthis("Destroyed AOE export: %s", "sudo vblade-persist destroy %s %s" % (self.aoe_device[1], self.aoe_device[3]))
def runthis(desc, cmd): if FLAGS.fake_network: return execute(cmd) else: return utils.runthis(desc,cmd)