示例#1
0
 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")
示例#2
0
 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']))
示例#3
0
文件: storage.py 项目: jxta/cc
 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))
示例#4
0
 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]))
示例#5
0
 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']))
示例#6
0
 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))
示例#7
0
文件: node.py 项目: jxta/cc
 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)
示例#8
0
 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))
示例#9
0
 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))
示例#10
0
文件: node.py 项目: bopopescu/cc-1
 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)
示例#11
0
文件: node.py 项目: bopopescu/cc-1
 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)
示例#12
0
文件: node.py 项目: sorenh/cc
 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)
示例#13
0
 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)
示例#14
0
 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)
示例#15
0
 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']))
示例#16
0
 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)
示例#17
0
文件: cloud.py 项目: yosh/nova
 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)
示例#18
0
 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))
示例#19
0
 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)
示例#20
0
文件: node.py 项目: sorenh/cc
 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)
示例#21
0
    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)
示例#22
0
文件: cloudpipe.py 项目: xtoddx/nova
    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)
示例#23
0
 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))
示例#24
0
 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)
示例#25
0
 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")
示例#26
0
 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)
示例#27
0
 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']))
示例#28
0
 def _delete_lv(self):
     utils.runthis(
         "Removing LV: %s",
         "sudo lvremove -f %s/%s" % (FLAGS.volume_group, self['volume_id']))
示例#29
0
 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")
示例#30
0
 def _create_lv(self, size):
     runthis("Creating LV: %s", "sudo lvcreate -L %s -n %s %s" % (size, self.volume_id, FLAGS.volume_group))
示例#31
0
 def _create_lv(self, size):
     runthis(
         "Creating LV: %s", "sudo lvcreate -L %s -n %s %s" %
         (size, self.volume_id, FLAGS.volume_group))
示例#32
0
文件: storage.py 项目: jxta/cc
 def _delete_lv(self):
     utils.runthis("Removing LV: %s", "sudo lvremove -f %s/%s" % (FLAGS.volume_group, self.volume_id))
示例#33
0
文件: storage.py 项目: jxta/cc
 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))
示例#34
0
文件: storage.py 项目: jxta/cc
 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))
示例#35
0
文件: storage.py 项目: jxta/cc
 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")
示例#36
0
 def _delete_lv(self):
     runthis(
         "Removing LV: %s",
         "sudo lvremove -f %s/%s" % (FLAGS.volume_group, self.volume_id))
示例#37
0
文件: storage.py 项目: jxta/cc
 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]))
示例#38
0
def runthis(desc, cmd):
    if FLAGS.fake_network:
        return execute(cmd)
    else:
        return utils.runthis(desc,cmd)
示例#39
0
文件: node.py 项目: sorenh/cc
 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")